package thread;

public class Demo {
   static boolean Quit = false;

    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            while (!Quit) {
                System.out.println("hello");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
    }
    t.start;
    Thread.sleep(5000);
    Quit = true;
}
